﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace TCCHWLib
{
    public class WriteSet
    {
        IDictionary<int, object> m_Buffer = new Dictionary<int, object>();
        Size m_Capacity;
        public Size Capacity
        {
            get { return m_Capacity; }
            set { m_Capacity = value; }
        }
        public IDictionary<int, object> Buffer
        {
            get { return m_Buffer; }
            set { m_Buffer = value; }
        }

        public object this[int index]
        {
            get { return m_Buffer[index]; }
        }

        public WriteSet(Size capacity)
        {
            m_Capacity = capacity;
        }

        public void Write(int address, object value)
        {
            if (m_Buffer.ContainsKey(address))
            {
                m_Buffer[address] = value;
                return;
            }
            if (m_Buffer.Count < m_Capacity.Height)
                m_Buffer.Add(address, value);
            else 
                new Exception ("Write Set over Flow");
        }

        public void Reset()
        {
            m_Buffer.Clear();
        }


    }
}
